<?php
require __DIR__.'/libs/Smarty.class.php';
$smarty=new Smarty();
$smarty->assign('t1',123);//创建模板变量,变量值什么类型都可以
//$smarty->display('e.html');//引用模板
//var_export($smarty->getTemplateDir());//array ( 0 => '/mnt/hgfs/wbr/testwork/templates/', )显示当前所有的模板文件夹
//$smarty->setTemplateDir(__DIR__.'/template/work');//设置当前所有的模板文件夹位置
//$smarty->display('index.html');
$smarty->addTemplateDir(__DIR__.'/template/home');//添加模板文件夹
//$smarty->display('head.html');//引用work模板
//$smarty->display('home/head.html');//引用home模板,相当于__DIR__.'/'.home/head.html
//var_export($smarty->getTemplateDir());
////array ( 0 => '/mnt/hgfs/wbr/testwork/template/work/', 1 => '/mnt/hgfs/wbr/testwork/template/home/', )
//$smarty->assign('data',array(1,2,3,4));
/*Smarty对数组的使用：数组[下标]、数组.下标
 * 遍历数组
{foreach $data as $k=>$v}
    { $k}=>{$v}<br>
{/foreach}
*/
/*$smarty->assign('data',array(
    'a1'=>array('title'=>'php','java'),
    'a2'=>array('css','html'),
));*/
/*遍历二维数组
{foreach $data as $k=>$v}
    {$v[0]}<br> 输出php css
   {$v['title']}<br>输出php
   {/foreach}*/

//$smarty->assign('data',array());
/*
 {foreach $data as $k=>$v}
       {$v['title']}<br>
       {foreachelse}
            没有内容
   {/foreach}
*/

//$smarty->assign('data',array(1,2,3,4));
//{section name=ke loop=要循环的变量 show=决定是否对于这块进行显示。默认为true}
/*
 {section name=ke loop=$data show=true}
    {$data[ke]}
{/section}
  */
$smarty->assign('data',array(
    array('php'=>1,'java'=>2),
    array('php'=>3,'java'=>4)
));

/*$smarty->assign('bool',true);
$smarty->display('index.html');*/




